package com.lzw.controller;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuzw
 * @date 2024/3/8
 */
@RefreshScope
@RestController
public class Main {

    @Value("${com.test}")
    private String value;
    @Autowired
    private Environment environment;

    @Autowired
    private StringEncryptor encryptor;

    @RequestMapping("/value")
    public String getName() {
        return environment.getProperty("com.test");
    }

    @RequestMapping("/encryptor")
    public String encryptor() {
        return encryptor.encrypt(value);
    }
}
